def sortColumns(matrix):
    
    rows=len(matrix)
    cols=len(matrix[0])
    
    sorted_matrix=[[0]*cols for _ in range(rows)]
    
    for col in range(cols):
        col_elements = [row[col] for row in matrix]
        col_elements.sort()
        for row in range(rows):
            sorted_matrix[row][col] = col_elements[row]
            
    return sorted_matrix
def main():
    mx1 = []
    n = int(input())
    for i in range(n):
        numbers = [ eval(x) for x in input().split() ]
        mx1.append(numbers)
    mx2 = sortColumns(mx1)
    for row in mx2:
        print(" ".join(map(str,row)))
    
if __name__ == "__main__":
    main()